How to Use substring()

This classic substring() function has two syntax in Postgres, you can use any of them.

select substring('hello how are you', 7,3)         as syntax_1, 
       	 substring('hello how are you' from 7 for 3) as syntax_2
syntax_1 syntax_2
how how

The second parameter specifies the position where the substring starts and the third parameter is the length of the substring to extract. If the length parameter is omitted, the substring to extract is until the end of the source string.

IN THIS PAGE